package cn.edu.zafu.bigdata.zengyadian;

public class ArithmeticExceptionExample {
    public static int divide(int a, int b) {
        if (b == 0) {
            throw new ArithmeticException("除数不能为 0");
        }
        return a / b;
    }

    public static void main(String[] args) {
        try {
            int result = divide(10, 0);
            System.out.println("结果为：" + result);
        } catch (ArithmeticException e) {
            System.out.println("发生错误：" + e.getMessage());
        }
    }
}